package com.jxd.reportsys.controller;

import com.jxd.reportsys.model.Emp;
import com.jxd.reportsys.service.IEmpService;
import com.jxd.reportsys.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @ClassName LoginController
 * @Description TODO
 * @Author 朱隶文
 * @Date 2024/9/20 9:41
 * @Version 1.0
 */
@RestController
public class LoginController {

    @Autowired
    private IUserService userService;
    @Autowired
    private IEmpService empService;

    @RequestMapping("/login")
    public Emp login(@RequestBody Map<String, String> map) {
        int empno = 0;
        String uname = map.get("uname");
        String pwd = map.get("pwd");
        empno = userService.login(uname, pwd);
        Emp emp = empService.getEmpByEmpno(empno);
        return emp;
    }
}
